a = [142,138,150,165,156,148,132,160]; 
x = sum(a)/8;%查表得标准正态分布函数上 0.025 分位点为 1.96；
lowedge = x - 4/sqrt(8)*1.96; 
highedge = x + 4/sqrt(8)*1.96; 
fprintf('置信区间为：[%f %f]',lowedge,highedge)




k = input('需要进行次数：'); 
m = 0;  
for i = 1:k 
    x = random('normal',120,16,1,3000); 
    x1 = sum(x)/3000;
    lowedge = x1 - 16/sqrt(3000)*1.96; %选择置信度为 95% 
    highedge = x1 + 16/sqrt(3000)*1.96; 
    if (lowedge <= 120)&&(120 <= highedge) 
        m = m+1; 
    end
end
believe_extent = m/k